package com.uzai.console.web.sop;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.sop.soptask.SopTaskDto;
import com.uzai.console.dto.sop.soptask.SopTaskIdDto;
import com.uzai.console.dto.sop.soptask.SopTaskQuery;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.sop.SopTaskService;
import com.uzai.console.vo.sop.soptask.SopTaskVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * SOP任务
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "SOP任务",tags = "客户维护|SOP任务")
@ApiSort(31)
@RestController
public class SopTaskController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(SopTaskController.class);

    @Autowired
    private SopTaskService sopTaskService;

    @ApiOperation(value = "分页查询SOP任务列表", notes = "分页查询SOP任务列表", response = SopTaskVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/sopTask/findByPage")
    public Object findSopTaskPage(@RequestBody SopTaskQuery sopTaskQuery){
        return sopTaskService.findSopTaskList(sopTaskQuery);
    }

    @ApiOperation(value = "查询SOP任务详情", notes = "查询SOP任务详情", response = SopTaskVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/sopTask/findById")
    public Object findSopTask(@RequestBody SopTaskIdDto sopTaskIdDto){
        return sopTaskService.findSopTask(sopTaskIdDto);
    }

    @SystemLogType(model = SystemModelEnum.SopTask, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加SOP任务", notes = "添加SOP任务")
    @ApiOperationSupport(order = 3)
    @PostMapping("/sopTask/add")
    public Object addSopTask(@RequestBody SopTaskDto sopTaskDto){
        sopTaskService.addSopTask(sopTaskDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.SopTask, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑SOP任务", notes = "编辑SOP任务")
    @ApiOperationSupport(order = 4)
    @PostMapping("/sopTask/update")
    public Object updateSopTask(@RequestBody SopTaskDto sopTaskDto){
        sopTaskService.updateSopTask(sopTaskDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.SopTask, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除SOP任务", notes = "删除SOP任务")
    @ApiOperationSupport(order = 5)
    @PostMapping("/sopTask/delete")
    public Object deleteSopTask(@RequestBody SopTaskIdDto sopTaskIdDto){
        sopTaskService.deleteSopTask(sopTaskIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.SopTask, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "停止SOP任务", notes = "停止SOP任务")
    @ApiOperationSupport(order = 6)
    @PostMapping("/sopTask/stop")
    public Object stopSopTask(@RequestBody SopTaskIdDto sopTaskIdDto){
        sopTaskService.stopSopTask(sopTaskIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.SopTask, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "开启SOP任务", notes = "开启SOP任务")
    @ApiOperationSupport(order = 7)
    @PostMapping("/sopTask/start")
    public Object startSopTask(@RequestBody SopTaskIdDto sopTaskIdDto){
        sopTaskService.startSopTask(sopTaskIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.SopTask, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "重置SOP任务", notes = "重置SOP任务")
    @ApiOperationSupport(order = 8)
    @PostMapping("/sopTask/reset")
    public Object resetSopTask(@RequestBody SopTaskIdDto sopTaskIdDto){
        sopTaskService.resetSopTask(sopTaskIdDto);
        return true;
    }

}
